<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.Statement" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/common/config.jsp" %>
<html>
<head>
    <title>查看详情</title>
</head>
<body>

<%
    String id = request.getParameter("id");
    String name = "";
    String password = "";
    String phone = "";
    String clazz = "";
    String homePath = "";
    if (id == "" || "".equals(id)) {
        out.print("不是正确的学生学号，页面将在5秒内跳转到学生列表页面。");
        out.print("<a href=\"query.jsp\">立即跳转</a>");
        response.setHeader("refresh", "5;URL=query.jsp");
    } else {
        String sql = "select * from t_user where id='" + id + "'";
        ResultSet rs = stmt.executeQuery(sql);
        if (rs.next()) {
            name = rs.getString("NAME");
            password = rs.getString("PASSWORD");
            phone = rs.getString("PHONE");
            clazz = rs.getString("CLAZZ");
            homePath = rs.getString("HOME_PATH");
        }else{
            out.print("学生信息不存在");
            out.print("<a href=\"query.jsp\">立即跳转</a>");
            response.setHeader("refresh", "5;URL=query.jsp");
        }
        conn.close();
    }
%>

<center>
    <h1><%=name%>同学的详细信息</h1>
<table border="1px" width="400px">
    <tr>
        <td width="10px">学号：</td>
        <td>
            <%=id%>
        </td>
    </tr>
    <tr>
        <td>姓名：</td>
        <td>
            <%=name%>
        </td>
    </tr>
    <tr>
        <td>电话：</td>
        <td>
            <%=phone%>
        </td>
    </tr>
    <tr>
        <td>密码：</td>
        <td>
            <%=password%>
        </td>
    </tr>
    <tr>
        <td>班级：</td>
        <td>
            <%=clazz%>
        </td>
    </tr>
    <tr>
        <td>根路径：</td>
        <td>
            <%=homePath%>
        </td>
    </tr>

    <tr>
        <td colspan="2" align="center">
            <a href="query.jsp">返回列表</a>
        </td>
    </tr>
</table>
</center>
</body>
</html>
